# -*- coding: utf-8 -*-
# @Time    : 2024/8/30 13:41
# @Author  : qd
# @Email   : 1518603573@qq.com
# @File    : fiance_ysk_page.py
# @Software: PyCharm
from selenium.webdriver.common.by import By
from pages.base_page import BasePage
from selenium.webdriver.common.alert import Alert
"""应收款主页,应付款，付款单，收款单的进入按钮都在这里"""
class FianceYskPage(BasePage):
    url="/crm/index.php?m=finance&a=index&t=receivables"
    """添加应收款按钮定位器"""
    ysk_btn_add_locator=(By.CSS_SELECTOR,"body > div.container > div.row > div:nth-child(1) > div.pull-right > a:nth-child(1)")
    """获取搜索后的应收款名定位器"""
    ysk_after_search_text_locator=(By.CSS_SELECTOR,"#form1 > table > tbody > tr:nth-child(1) > td:nth-child(2) > a")
    """应收款关键字搜索框定位器"""
    ysk_input_search_locator = (By.ID, "search")
    """搜索按钮定位器"""
    ysk_btn_search_locator = (By.CSS_SELECTOR, "#searchForm > ul > li:nth-child(4) > button")
    """要删除的应收款1定位器"""
    ysk1_locator = (By.CSS_SELECTOR, "#form1 > table > tbody > tr:nth-child(1) > td:nth-child(1) > input")
    """要删除的所有应收款定位器"""
    ysk_all_locator = (By.ID, "check_all")
    """删除按钮定位器"""
    ysk_btn_delete_locator = (By.ID, "delete")
    """应付款定位器"""
    yfk_btn_locator = (By.CSS_SELECTOR, "body > div.container > div.page-header > ul > li:nth-child(2) > a")
    """收款单定位器"""
    skd_btn_locator = (By.CSS_SELECTOR, "body > div.container > div.page-header > ul > li:nth-child(3) > a")
    """付款单定位器"""
    fkd_btn_locator = (By.CSS_SELECTOR, "body > div.container > div.page-header > ul > li:nth-child(4) > a")

    """点击添加应收款按钮"""
    def click_ysk_btn_add(self):
        self.driver.find_element(*self.ysk_btn_add_locator).click()

    """输入应收款的关键字"""
    def input_ysk_search(self,ysk_keywords):
        self.driver.find_element(*self.ysk_input_search_locator).send_keys(ysk_keywords)

    """点击添加搜索按钮"""
    def click_ysk_btn_search(self):
        self.driver.find_element(*self.ysk_btn_search_locator).click()

    def get_after_search_text(self):
        return self.driver.find_element(*self.ysk_after_search_text_locator).text.strip()
    """选中一条要删除的应收款"""
    def click_ysk1(self):
        self.driver.find_element(*self.ysk1_locator).click()
    """选中要删除的应收款"""
    def click_all_ysk(self):
        self.driver.find_element(*self.ysk_all_locator).click()
    """点击删除按钮"""
    def click_ysk_btn_delete(self):
        self.driver.find_element(*self.ysk_btn_delete_locator).click()

    """点击确定删除"""
    def click_ysk_alert(self):
        self.driver.switch_to.alert.accept()

    """点击进入应付款界面"""
    def click_yfk_btn(self):
        self.driver.find_element(*self.yfk_btn_locator).click()

    """点击进入收款单界面"""
    def click_skd_btn(self):
        self.driver.find_element(*self.skd_btn_locator).click()

    """点击进入付款单界面"""
    def click_fkd_btn(self):
        self.driver.find_element(*self.fkd_btn_locator).click()
    """"获取全部删除后的文本"""
    def get_ysk_after_delete_text(self):
        return self.driver.find_element(*self.ysk_after_delete_text_locator).text.strip()

